/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package mundo;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author USUARIO WINDOWS
 */
@Entity
@Table(name = "costo_historico")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CostoHistorico.findAll", query = "SELECT c FROM CostoHistorico c"),
    @NamedQuery(name = "CostoHistorico.findByFechaInicio", query = "SELECT c FROM CostoHistorico c WHERE c.costoHistoricoPK.fechaInicio = :fechaInicio"),
    @NamedQuery(name = "CostoHistorico.findByFechaFin", query = "SELECT c FROM CostoHistorico c WHERE c.fechaFin = :fechaFin"),
    @NamedQuery(name = "CostoHistorico.findByCosto", query = "SELECT c FROM CostoHistorico c WHERE c.costo = :costo"),
    @NamedQuery(name = "CostoHistorico.findByIdProducto", query = "SELECT c FROM CostoHistorico c WHERE c.costoHistoricoPK.idProducto = :idProducto")})
public class CostoHistorico implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CostoHistoricoPK costoHistoricoPK;
    @Column(name = "fechaFin")
    @Temporal(TemporalType.DATE)
    private Date fechaFin;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "Costo")
    private Double costo;
    @JoinColumn(name = "idProducto", referencedColumnName = "idProducto", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Producto producto;

    public CostoHistorico() {
    }

    public CostoHistorico(CostoHistoricoPK costoHistoricoPK) {
        this.costoHistoricoPK = costoHistoricoPK;
    }

    public CostoHistorico(Date fechaInicio, int idProducto) {
        this.costoHistoricoPK = new CostoHistoricoPK(fechaInicio, idProducto);
    }

    public CostoHistoricoPK getCostoHistoricoPK() {
        return costoHistoricoPK;
    }

    public void setCostoHistoricoPK(CostoHistoricoPK costoHistoricoPK) {
        this.costoHistoricoPK = costoHistoricoPK;
    }

    public Date getFechaFin() {
        return fechaFin;
    }

    public void setFechaFin(Date fechaFin) {
        this.fechaFin = fechaFin;
    }

    public Double getCosto() {
        return costo;
    }

    public void setCosto(Double costo) {
        this.costo = costo;
    }

    public Producto getProducto() {
        return producto;
    }

    public void setProducto(Producto producto) {
        this.producto = producto;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (costoHistoricoPK != null ? costoHistoricoPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CostoHistorico)) {
            return false;
        }
        CostoHistorico other = (CostoHistorico) object;
        if ((this.costoHistoricoPK == null && other.costoHistoricoPK != null) || (this.costoHistoricoPK != null && !this.costoHistoricoPK.equals(other.costoHistoricoPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "mundo.CostoHistorico[ costoHistoricoPK=" + costoHistoricoPK + " ]";
    }
    
}
